import 'package:flutter/material.dart';
import 'package:mysql1/mysql1.dart';

class SignalCountInfo{
  int id = 0;
  String signalTrigger = "";
  String signalTriggerCn = "";
  int count = 0;


  SignalCountInfo(this.id, this.signalTrigger, this.signalTriggerCn);

  static Map<String,SignalCountInfo> buildSignalInfoMap(){
    Map<String,SignalCountInfo> signalInfoMap =  <String,SignalCountInfo>{};
    signalInfoMap["A11 OFF"] = SignalCountInfo(1, "A11 OFF", "回路故障");
    signalInfoMap["18DS ON"] = SignalCountInfo(2, "18DS ON", "机门全开");
    signalInfoMap["DLS COUNT"] = SignalCountInfo(3, "DLS COUNT", "保险刀触发");
    signalInfoMap["CC OFF"] = SignalCountInfo(4, "CC OFF", "故障");
    signalInfoMap["RUN ON OR DC OFF"] = SignalCountInfo(5, "RUN ON OR DC OF", "行机跌闸锁");
    signalInfoMap["NP OFF"] = SignalCountInfo(6, "NP OFF", "电源故障");
    signalInfoMap["Door abnormal ON"] = SignalCountInfo(7, "Door abnormal ON", "机门故障");
    signalInfoMap["EXOL ON"] = SignalCountInfo(8, "EXOL ON", "机门运行过载");
    signalInfoMap["18DS ON + DC ON"] = SignalCountInfo(9, "18DS ON + DC ON", "机门全开但闸锁不跌");
    signalInfoMap["Door PCB abnormal"] = SignalCountInfo(10, "Door PCB abnormal", "Door PCB abnormal故障");
    return signalInfoMap;
  }

  static builder(ResultRow row,Map<String,SignalCountInfo> signalInfoMap) {
    String signalTrigger = null==row[0]?"":row[0].toString();
    int count = row[1].toInt();
    if(signalInfoMap.containsKey(signalTrigger)){
      SignalCountInfo? signalCountInfo = signalInfoMap[signalTrigger];
      signalCountInfo?.count = count;
    }
  }
}